#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<signal.h>

void sig(int signo)
{
	printf("catch %d\n",signo);
}

int main()
{
	if (fork() == 0)
	{
		/* 子进程 */
		if (setsid() < 0)
		{
			perror("setsid error");
			exit(2);
		}
		int i;
		for (i = 0; i < 32; i++)
			if (signal(i,sig) < 0)
			{
				printf("signal %d handler set error\n",i);
			}
		printf("pid %u\n",getpid());
		while(1)
		{
			int t = 123;
			sleep(8);
			printf("diff_session_tty_output\n");
			printf("%d\n",scanf("%d",&t));
		}
	} 
	return 0;
}
